package com.xnyzc.lhy.order.controller.capi.address.collect;


import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.penum.capi.collect.address.ECollectAddressType;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.order.service.user.address.IOaCAddressCollectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 地点收藏 前端控制器
 * </p>
 *
 * @author bin
 * @since 2019-07-19
 */
@RestController
@RequestMapping("oa/collect/address")
public class OaCAddressCollectController {

    @Autowired
    private IOaCAddressCollectService iOaCAddressCollectService;

    /**
     * 用户收藏地址
     * @return
     */
    @ApiOperation(value = "获取用户收藏历史地址", notes = "获取用户收藏历史地址")
    @GetMapping(value = "selectAddress")
    public Rv selectAddress(@RequestParam(value = "current") long current){
        long userId = TokenUtil.getTokenUserId();
        if (userId == 0){
            throw PangException.create(EErrorCode.tokenExpire);
        }
        return Rv.wrap(iOaCAddressCollectService.getAddressCollect(userId, current, ECollectAddressType.home.getDesc(), ECollectAddressType.company.getDesc()));
    }
}
